<?php

namespace app\gptcms\controller\api;
use app\gptcms\controller\BaseApi;
use think\facade\Db;
use think\facade\Session;

class Card extends BaseApi
{
	public function conversion(){
		$wid = Session::get('wid');
        $user = $this->user;
        $code = $this->req->param("code");
        $info = Db::table("kt_gptcms_card_detail")->where(["code"=>$code])->find();
        if(!$info)return error("操作失败，卡密错误或不存在");
        $detail["time"] = date("Y-m-d H:i:s");
        $detail["user"] = $user["id"];
        $detail["status"] = 1;
        $res = Db::table("kt_gptcms_card_detail")->where(["id"=>$info["id"]])->update($detail);
        if($res)return success("操作成功");
        return error("操作失败");
	}
}